async function fn1() {
    return 100
}

const res = fn1()    // 返回的是promise对象
console.log('res', res) // 打印出promise
res.then(res => {
    console.log(res)
})

!(async function () {
    const p1 = Promise.resolve(500)
    const data = await p1  // await 相当于 promise的then
    console.log('data', data)
})()

!(async function () {
    const data = await 400  // 相当于 promise.resolve(400)
    console.log('data', data)
})()

!(async function () {
    const p4 = Promise.reject('err')
    try {
        const res = await p4
        console.log('res', res)
    } catch (e) {
        console.log(e) // try……cathc相当于promise的catch
    }
})()

!(async function () {
    const p4 = Promise.reject('err') //rejected 状态
    const res2 = await p4  // await 相当于 promise的then  所以下方代码不会执行会报错
    console.log('res2', res2)
})()